package com.mrjoew.weekend;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Christopher Jones
 * @desc
 * @since 2020/12/12 0012 23:14
 */
@Component
public class KafkaConsumer {

    @KafkaListener(groupId = "weekend", topics = "requests")
    public void onMessage(ConsumerRecord<?, ?> record) {
        Map<String, String> map = JSON.parseObject(
                record.value().toString(), new TypeReference<HashMap<String, String>>() {});
    }
}
